package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.common.DeliveryType;
import com.ap.core.cxf.jaxb.paymentdetails.TransactionStatusCode;
import com.ap.core.cxf.jaxb.rtp.TransactionCheckOutType;
import com.ap.core.message.managepayment.info.ConfirmPaymentRequestMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.OriginalInfo;
import com.ap.core.validation.message.info.RTPOriginalInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User:Ranjit.Singh
 * This message element will hold the address of the purchased goods in the event that the 'TransactionCheckOutType'<TxCheckout> ='QKPACHK' in the original request message ‘AP004.01’(RTP for Authorization)
 */
public class ValidQuickPayAddressCheckRule extends AbstractValidationRule<MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfo>> {

	@Override
	public boolean validate(MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfo> infoObject) {
        boolean pass = false;
		if(TransactionCheckOutType.QKPACHK.equals(infoObject.getOriginalInfo().getTransactionCheckOutType()) && !DeliveryType.DIGDEL.equals(infoObject.getOriginalInfo().getDeliveryType())){
            pass = null != infoObject.getBoundObject().getPaymtDetails().getQkPayDelAddress();
		} else{
            pass = null == infoObject.getBoundObject().getPaymtDetails().getQkPayDelAddress();
        }
		return pass;
	}

}

